 <?php
//这个wishupdate.php有两个功能，第一是显示旧留言，第二将修改后的留言填回数据库

//根据传过来的留言的ID，显示这条留言
 header("Content-Type:text/html;charset=utf-8");//防止网页中文乱码
require 'dbcon.php';
 $id=isset($_GET['id']) ? $_GET['id']:0;
 if(empty ($_POST))
 {
      $rs=$db->query("select*from tb_note where id='{$id}'");
      $k=$rs->fetch_assoc();
      require("edit_html.php");
 }
 else{
 $name=$_REQUEST['name'];
 $message=$_REQUEST['message'];
 date_default_timezone_set('Asia/Shanghai');
 $date=date("Y-m-d h:i:s");
 $sql="update tb_note set name='$name',message='$message',date='$date'  where id='{$id}'";
//echo $sql;

//exit;

 $rs=$db->query($sql);

 if ($rs==true)
 {
     echo "<script language='javascript' type='text/javascript'>";
     echo "alert('修改成功!');";
     echo "window.location.href='index.php';";
     echo "</script>";
 }
 else{
      echo "<script language='javascript' type='text/javascript'>";
     echo "alert('修改失败!');";
     echo "window.location.href='index.php';";
     echo "</script>";
 }
 }

